package com.study.service.FDservice;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.study.model.jdao.FDjdao.FinanceDao;
import com.study.model.mdao.FDmdao.FinanceMapper;
import com.study.model.pojo.FDpojo.Finance;

@Service
public class FinanceServices {
	@Autowired
	FinanceDao dao;
	@Autowired
	FinanceMapper fm;
	/**
	 * 查询所有财务记录
	 * 
	 * @return
	 */
	/*public List<Finance> selectAll(){
		return (List<Finance>)dao.findAll();
	}*/
	
	/*
	 * public void delete(int id){ dao.deleteById(id); }
	 */
	
	public List<Finance> selectAll() {
		return (List<Finance>) dao.findAll();
	}

	public Boolean addNewFinance(Finance f) {
		try {
			dao.save(f);
			return true;
		} catch (Exception e) {
			// TODO: handle exception
		}
		return false;
	}
	/**
	 * 查询财务ID
	 * @return
	 */
	public List<Integer> findFinances(){
		return dao.findFiance();
	}
	
	/**
	 * 查询所有财务信息
	 * @return
	 */
	public List<Map<String, String>> selectFinancess(){			
		return fm.findfinance();
	}
	
	/**
	 * 查询财务类型单总额
	 * @returns
	 */
	public List<Map<String, String>> SelectFinanceSum(){
		return fm.findfinanceSum();		
	}
	/**
	 * 查询最近7天财务收支额度
	 * @returns
	 */
	public List<Map<String, String>> SelectFinanceSum7(){
		return fm.findfinanceSum7();		
	}
	
	/**
	 * 查询当天的财务收支情况
	 * @return
	 */
	public List<Map<String, String>> SelectFinanceTheDay(String thedate){
		return fm.findfinanceTheday(thedate);		
	}
	
	/**
	 * 根据id删除
	 * @param id
	 */
	public void delete(int id){
		dao.deleteById(id);
	}

	
}
